import java.awt.Color;
import java.awt.geom.Ellipse2D;

import org.kordamp.jsilhouette.geom.Arrow;


public class Ball {
	private double x,y;
	public final double r,m;
	private Vektor v;
	private Color color = Color.GREEN;
	public Color originalColor = color;
	public final int id;
	
	public Ball(int id, double x, double y, double r, double m, Vektor v, Color color) {
		this(id, x, y, r, m, v);
		this.color = color;
		this.originalColor = color;
	}
	
	public Ball(int id, double x, double y, double r, double m, Vektor v) {
		this.id = id;
		this.x = x;
		this.y = y;
		this.r = r;
		this.m = m;
		this.v = v;
	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	public Vektor getV() {
		return v;
	}

	public void setV(Vektor v) {
		this.v = v;
	}

	public Color getColor() {
		return color;
	}
	
	public void setColor(Color color) {
		this.color = color;
	}

	public Ellipse2D getEllipse() {
		return new Ellipse2D.Double(x - r, y - r, 2 * r, 2 * r);
	}
	
	public Arrow getArrow() {
		float xA = (float)x;
		float yA = (float)y;
		float width = (float)v.getMagnitude();
		float height = 0.5f;
		float rise = 0.3f;
		float depth = 0.8f;
		float angle = (float)v.getAngle();
		
		//public Arrow( float x, float y, float width, float height, float rise, float depth, float angle )
		return new Arrow((xA-(height/2)), yA, width, height, rise, depth, angle);
	}
	
	public void update(double x, double y, double vx, double vy) {
		this.x = x;
		this.y = y;
		v.setCathetusX(vx);
		v.setCathetusY(vy);
	}
	
	public Ball clone() {
		return new Ball(id, x, y, r, m, v.clone(), originalColor);
	}
	@Override
	public boolean equals(Object ball) {
		Ball b = ((Ball)ball);
		return (b.id == id);
	}
}
